package com.landeb.shop.huo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.landeb.shop.R;
import com.landeb.shop.huo.bean.BeanCoupon;

import java.util.List;

/**
 * Created by blade on 2017/9/29.
 */

public class DialogListAdapter extends BaseAdapter {

    private List<BeanCoupon.DataBean> mList;
    private Context mContext;
    private LayoutInflater mInflater;


    public DialogListAdapter(List<BeanCoupon.DataBean> list, Context context) {
        mList = list;
        mContext = context;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_dialog_list, parent, false);

            holder = new ViewHolder();
            holder.mItem = (TextView) convertView.findViewById(R.id.item_dialog_list_tv);

            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.mItem.setText(mList.get(position).getName());

//        if (mList.get(position).getAvailable().equals("0")) {
//            convertView.setEnabled(false);
//        }else {
//            convertView.setEnabled(true);
//        }

        return convertView;
    }


    private class ViewHolder {
        private TextView mItem; //文字
    }
}
